import java.util.Random;
import java.util.Scanner;

public class hgchg {
    public static void main(String[] args) {
     int[] data=new int[5];
        Random r= new Random();
        for (int i = 0; i < data.length; i++) {
            data[i]=r.nextInt(20)+1;
        }
        Scanner sc=new Scanner(System.in);
        OUT:
        while(true)
        {
            System.out.println("请您输入一个1~20之间的整数进行猜测：");
            int guessDate=sc.nextInt();
            for (int i = 0; i < data.length; i++) {
                if(data[i]==guessDate){
                    System.out.println("您已经猜中了该数据，运气不错！您猜中的索引是："+i);
                    break OUT;
                }
            }
            System.out.println("当前猜测的数据在数组中不存在，请重新猜测！");
        }
        for(int i=0;i< data.length;i++)
        {
            System.out.println(data[i]+"\t");
        }
    }
}
